#ifndef __WIZ_BNF_SCANNER_HPP__SHANHAOBO_19800429__
#define __WIZ_BNF_SCANNER_HPP__SHANHAOBO_19800429__

#include "./WizBNFPolicies.hpp"

namespace Wiz
{
    namespace BNF
    {
        namespace Scanner
        {
            namespace Linker
            {
                template<typename ScannerT>
                struct Type : public ScannerT
                {
                    Type(ScannerT const Scan) : ScannerT(Scan)
                    {}
                };
            } /// end of namespace Linker

            template <typename IteratorT, typename PoliciesT>
            class Type : public PoliciesT
            {
            public:
                typedef Type<IteratorT, PoliciesT>                                          tThis;
                typedef PoliciesT                                                           tSuper;
                typedef IteratorT                                                           tIterator;
                typedef typename ::Wiz::TypeTraits::tIterator::Type<tIterator>::value_type   tValue;
                typedef typename ::Wiz::TypeTraits::tIterator::Type<tIterator>::reference    tReference;
                typedef tIterator const&                                                    tIterParam;
            public:
                //Type(IteratorT& Curr, IteratorT const& Lst) : m_Curr(Curr), m_Last(Lst)
                //{}
                Type(IteratorT& Curr, tIterParam Lst, PoliciesT const& Plcy = PoliciesT())
                    : tSuper(Plcy), m_Curr(Curr), m_Last(Lst)
                {
                    AtEnd();
                }

                Type(tThis const& Other)
                    : tSuper(Other), m_Curr(Other.m_Curr), m_Last(Other.m_Last)
                {}


                Type(tThis const& Other, IteratorT& Curr)
                    : tSuper(Other), m_Curr(Curr), m_Last(Other.m_Last)
                {}

                template <typename PoliciesT2>
                Type(Type<IteratorT, PoliciesT2> const& Other)
                    : tSuper(Other), m_Curr(Other.m_Curr), m_Last(Other.m_Last)
                {}

            public:
                ::Wiz::Bool::Type AtEnd() const
                {
                    typedef typename PoliciesT::tIterationPolicy tIterationPolicy;
                    return tIterationPolicy::AtEnd(*this);
                }

                tValue operator*() const
                {
                    typedef typename PoliciesT::tIterationPolicy tIterationPolicy;
                    return tIterationPolicy::Filter(tIterationPolicy::Get(*this));
                }

                tThis const& operator++() const
                {
                    typedef typename PoliciesT::tIterationPolicy tIterationPolicy;
                    tIterationPolicy::Advance(*this);
                    return *this;
                }

                template<typename PoliciesT2>
                Type<IteratorT, PoliciesT2>
                ChangePolicies(PoliciesT2 const& policies) const
                {
                    return Type<IteratorT, PoliciesT2>(m_Curr, m_Last, policies);
                }

            public:
                tIterator&          m_Curr;
                tIterator const     m_Last;

            private:
                tThis& operator=(tThis const& Other);
            };

            namespace Phrase
            {
                typedef ::Wiz::BNF::Scanner::Type<::Wiz::Char::Type const*, ::Wiz::BNF::Policy::Skipper::Scanner::Type>    Type;
            } /// end of namespace Phrase
        } /// end of namespace Scanner
    } /// end of namespace BNF
} /// end of namespace Wiz

#endif /*__WIZ_BNF_SCANNER_HPP__SHANHAOBO_19800429__*/
